// eslint-disable-next-line
import { UserLayout, BasicLayout, BlankLayout } from '@/layouts'
import { bxAnaalyse } from '@/core/icons'

const RouteView = {
  name: 'RouteView',
  render: (h) => h('router-view')
}

export const asyncRouterMap = [

  {
    path: '/',
    // name: 'index',
    name: 'index',
    component: BasicLayout,
    meta: { title: 'menu.home' },
    redirect: '/dashboard/workplace',
    children: [
      // dashboard
      {
        path: '/dashboard',
        name: '',
        redirect: '/dashboard/workplace',
        component: RouteView,
        meta: { title: 'menu.dashboard', keepAlive: true, icon: bxAnaalyse, permission: [ 'workplace' ] },
        children: [
          {
            path: '/dashboard/workplace',
            name: 'Workplace',
            component: () => import('@/views/dashboard/Workplace'),
            meta: { title: 'menu.dashboard.workplace', keepAlive: true, permission: [ 'workplace' ] }
          }
        ]
      },

      // 服务器管理
      {
        path: '/servermanagement',
        // name: '服务器管理',
        name: 'servermanagement',
        redirect: '/servermanagement/accesslog',
        component: RouteView,
        meta: { title: 'menu.servermanagement', keepAlive: true, icon: bxAnaalyse, permission: [ 'servermanagement' ] },
        children: [
          {
            path: '/servermanagement/accesslog',
            // name: '访问日志',
            name: 'accesslog',
            component: () => import('@/views/servermanagement/accesslog'),
            meta: { title: 'menu.servermanagement.accesslog', keepAlive: true, permission: [ 'servermanagement_accesslog' ] }
          }
        ]
      },

      // 角色管理
      {
        path: '/rolemanagement',
        // name: '角色管理',
        name: 'rolemanagement',
        redirect: '/rolemanagement/userrole',
        component: RouteView,
        meta: { title: 'menu.rolemanagement', keepAlive: true, icon: bxAnaalyse, permission: [ 'rolemanagement' ] },
        children: [
          {
            path: '/rolemanagement/userrole',
            // name: '用户角色管理',
            name: 'userrole',
            component: () => import('@/views/rolemanagement/userrole'),
            meta: { title: 'menu.rolemanagement.userrole', keepAlive: true, permission: [ 'rolemanagement_userrole' ] }
          },
          {
            path: '/rolemanagement/role',
            // name: '角色管理',
            name: 'role',
            component: () => import('@/views/rolemanagement/role'),
            meta: { title: 'menu.rolemanagement.role', keepAlive: true, permission: [ 'rolemanagement_role' ] }
          }
        ]
      },

      // 用户信息管理
      {
        path: '/usermanagement',
        // name: '用户信息管理',
        name: 'usermanagement',
        redirect: '/usermanagement/userinfo',
        component: RouteView,
        meta: { title: 'menu.usermanagement', keepAlive: true, icon: bxAnaalyse, permission: [ 'usermanagement' ] },
        children: [
          {
            path: '/usermanagement/userinfo',
            // name: '用户信息管理',
            name: 'userinfomanagement',
            component: () => import('@/views/usermanagement/userinfo'),
            meta: { title: 'menu.usermanagement.userinfo', keepAlive: true, permission: [ 'usermanagement_userinfo' ] }
          },
          {
            path: '/usermanagement/authentification',
            // name: '用户信息认证',
            name: 'authentication',
            component: () => import('@/views/usermanagement/authentication'),
            meta: { title: 'menu.usermanagement.authentication', keepAlive: true, permission: [ 'usermanagement_authentication' ] }
          }
        ]
      },

      // 权限管理
      {
        path: '/permissionmanagement',
        // name: '权限管理',
        name: 'permissionmanagement',
        redirect: '/permissionmanagement/permissions',
        component: RouteView,
        meta: { title: 'menu.permissionmanagement', keepAlive: true, icon: bxAnaalyse, permission: [ 'permissionmanagement' ] },
        children: [
          {
            path: '/permissionmanagement/rolePermissions',
            // name: '角色权限管理',
            name: 'rolePermissions',
            component: () => import('@/views/permissionmanagement/rolePermissions'),
            meta: { title: 'menu.permissionmanagement.rolePermissions', keepAlive: true, permission: [ 'permissionmanagement_rolePermissions' ] }
          },
          {
            path: '/permissionmanagement/permissions',
            // name: '权限管理',
            name: 'permissions',
            component: () => import('@/views/permissionmanagement/permissions'),
            meta: { title: 'menu.permissionmanagement.permissions', keepAlive: true, permission: [ 'permissionmanagement_permissions' ] }
          }
        ]
      },

      // 信息管理
      {
        path: '/infomanagement',
        // name: '信息管理',
        name: 'infomanagement',
        redirect: '/infomanagement/invitation',
        component: RouteView,
        meta: { title: 'menu.infomanagement', keepAlive: true, icon: bxAnaalyse, permission: [ 'infomanagement' ] },
        children: [
          {
            path: '/infomanagement/announcement',
            // name: '公告管理',
            name: 'announcement',
            component: () => import('@/views/infomanagement/announcement'),
            meta: { title: 'menu.infomanagement.announcement', keepAlive: true, permission: [ 'infomanagement_announcement' ] }
          },
          {
            path: '/infomanagement/invitation',
            // name: '帖子管理',
            name: 'invitation',
            component: () => import('@/views/infomanagement/invitation'),
            meta: { title: 'menu.infomanagement.invitation', keepAlive: true, permission: [ 'infomanagement_invitation' ] }
          },
          {
            path: '/infomanagement/privateInvitation',
            // name: '我的帖子',
            name: 'privateInvitation',
            component: () => import('@/views/infomanagement/privateInvitation'),
            meta: { title: 'menu.infomanagement.privateInvitation', keepAlive: true, permission: [ 'infomanagement_privateInvitation' ] }
          },
          {
            path: '/infomanagement/feedback',
            // name: '反馈管理',
            name: 'feedback',
            component: () => import('@/views/infomanagement/feedback'),
            meta: { title: 'menu.infomanagement.feedback', keepAlive: true, permission: [ 'infomanagement_feedback' ] }
          },
          {
            path: '/infomanagement/slideshow',
            // name: '轮播图管理',
            name: 'slideshow',
            component: () => import('@/views/infomanagement/slideshow'),
            meta: { title: 'menu.infomanagement.slideshow', keepAlive: true, permission: [ 'infomanagement_slideshow' ] }
          }
        ]
      },

      // 用户信息
      {
        path: '/userinfo',
        // name: '用户信息',
        name: 'userinfo',
        redirect: '/userinfo/user',
        component: RouteView,
        meta: { title: 'menu.userinfo', keepAlive: true, icon: bxAnaalyse, permission: [ 'user' ] },
        children: [
          {
            path: '/userinfo/password',
            // name: '密码修改',
            name: 'password',
            component: () => import('@/views/userinfo/password'),
            meta: { title: 'menu.userinfo.password', keepAlive: true, permission: [ 'user_password' ] }
          },
          {
            path: '/userinfo/user',
            // name: '个人信息',
            name: 'user',
            component: () => import('@/views/userinfo/user'),
            meta: { title: 'menu.userinfo.user', keepAlive: true, permission: [ 'user_user' ] }
          }
        ]
      }
    ]
  },

  {
    path: '*', redirect: '/404', hidden: true
  }
]

/**
 * 基础路由
 * @type { *[] }
 */
export const constantRouterMap = [
  {
    path: '/user',
    component: UserLayout,
    redirect: '/user/login',
    hidden: true,
    children: [
      {
        path: 'login',
        name: 'login',
        component: () => import(/* webpackChunkName: "user" */ '@/views/user/Login')
      },
      {
        path: 'register',
        name: 'register',
        component: () => import(/* webpackChunkName: "user" */ '@/views/user/Register')
      },
      {
        path: 'register-result',
        name: 'registerResult',
        component: () => import(/* webpackChunkName: "user" */ '@/views/user/RegisterResult')
      },
      {
        path: 'recover',
        name: 'recover',
        component: undefined
      }
    ]
  },

  {
    path: '/404',
    component: () => import(/* webpackChunkName: "fail" */ '@/views/exception/404')
  }

]
